package com.hzq.htest.ui.login.activity;

import android.graphics.Color;
import android.os.Build;
import android.text.InputType;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;


import com.hzq.htest.R;
import com.hzq.htest.ui.login.bean.LoginfoBean;
import com.hzq.htest.ui.login.contract.LoginContract;
import com.hzq.htest.ui.login.model.LoginModel;
import com.hzq.htest.ui.login.presenter.LoginPresenter;

import butterknife.Bind;
import kstar.mycommon.base.BaseActivity;

import kstar.mycommon.commonwidget.SystemBarTintManager;
import okhttp3.FormBody;
import okhttp3.RequestBody;

/**
 * Created by ${GuoZhaoHui} on 2017/9/4.
 * email:guozhaohui628@gmail.com
 * 登陆界面
 */

public class LoginActivity extends BaseActivity<LoginPresenter, LoginModel> implements LoginContract.View {

    @Bind(R.id.et_login_name)
    EditText etLoginName;
    @Bind(R.id.et_login_psw)
    EditText etLoginPsw;
    @Bind(R.id.bt_login)
    Button btLogin;

    /**
     * 返回登陆接口请求参数
     * @return
     */
    @Override
    public RequestBody getRequestParams() {
        RequestBody body = new FormBody.Builder()
                .add("userName", etLoginName.getText().toString())
                .add("password", etLoginPsw.getText().toString())
                .build();
        return body;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    public void initPresenter() {
        mPresenter.setVM(this, mModel);
    }

    @Override
    public void initView() {
        /**
         * 默认着色状态栏(因为多个页面状态栏颜色不一致，所以不能放在BaseActivity中)
         */
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setTranslucentStatus(true);
        }
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        /**
         * 注意，一定要这样写 不能引用
         */
        tintManager.setStatusBarTintColor(Color.parseColor("#2078d9"));
    }


    @Override
    public void showLoading(String title) {
    }

    @Override
    public void stopLoading() {
    }

    @Override
    public void showErrorTip(String msg) {

    }

    @Override
    public void returnLoginInfo(LoginfoBean loginInfo) {

    }

}
